import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

traisitEnd(List list, index, hasmore, context) {
  ScreenUtil.instance = ScreenUtil(width: 750, height: 1334)..init(context);
  if (index == list.length - 1) {
    return Container(
      child: Column(
        children: <Widget>[
          ///起点 终点  和轨迹 Row排列方便
          Container(
            decoration:
                BoxDecoration(color: Colors.white, boxShadow: <BoxShadow>[
              BoxShadow(
                color: Colors.grey[400],
              ),
            ]),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: <Widget>[
                Expanded(
                    flex: 3,
                    child: Container(
                      color: Color.fromRGBO(255, 255, 255, 1),
                      child: Padding(
                        padding: EdgeInsets.fromLTRB(20, 10, 0, 10),
                        child: Column(
                          children: <Widget>[
                            Row(
                              children: <Widget>[
                                Container(
                                  width: ScreenUtil().setWidth(50),
                                  height: ScreenUtil().setHeight(50),
                                  color: Color(0xff62B500),
                                  margin: EdgeInsets.fromLTRB(0, 0, 10, 0),
                                  child: Center(
                                    child: Text(
                                      "起1",
                                      textAlign: TextAlign.center,
                                      style: TextStyle(
                                        fontSize: ScreenUtil().setSp(30),
                                        color: Colors.white,
                                      ),
                                    ),
                                  ),
                                ),
                                Container(
                                  width: ScreenUtil().setWidth(400),
                                  child: Text(
                                    list[index]['fromAddress'],
                                    overflow: TextOverflow.ellipsis,
                                    maxLines: 2,
                                    style: TextStyle(
                                      fontSize: ScreenUtil().setSp(32),
                                      color: Color(0xff0E0E0E),
                                    ),
                                  ),
                                ),
                              ],
                            ),
                            Container(
                              height: ScreenUtil().setHeight(50),
                              margin: EdgeInsets.fromLTRB(
                                  ScreenUtil().setHeight(20), 0, 0, 0),
                              decoration: BoxDecoration(
                                border: Border(
                                    left: BorderSide(
                                        color: Colors.grey[200],
                                        width: 1,
                                        style: BorderStyle.solid)),
                              ),
                            ),

                            ///起点
                            Row(
                              children: <Widget>[
                                Container(
                                  width: ScreenUtil().setWidth(50),
                                  height: ScreenUtil().setHeight(50),
                                  color: Color(0xff62B500),
                                  margin: EdgeInsets.fromLTRB(0, 0, 10, 0),
                                  child: Center(
                                    child: Text(
                                      "起2",
                                      textAlign: TextAlign.center,
                                      style: TextStyle(
                                        fontSize: ScreenUtil().setSp(30),
                                        color: Colors.white,
                                      ),
                                    ),
                                  ),
                                ),
                                Container(
                                  width: ScreenUtil().setWidth(400),
                                  child: Text(
                                    list[index]['fromAddress'],
                                    overflow: TextOverflow.ellipsis,
                                    maxLines: 2,
                                    style: TextStyle(
                                      fontSize: ScreenUtil().setSp(32),
                                      color: Color(0xff0E0E0E),
                                    ),
                                  ),
                                ),
                              ],
                            ),
                            Container(
                              height: ScreenUtil().setHeight(50),
                              margin: EdgeInsets.fromLTRB(
                                  ScreenUtil().setHeight(20), 0, 0, 0),
                              decoration: BoxDecoration(
                                border: Border(
                                    left: BorderSide(
                                        color: Colors.grey[200],
                                        width: 1,
                                        style: BorderStyle.solid)),
                              ),
                            ),

                            ///终点
                            Row(
                              children: <Widget>[
                                Container(
                                  width: ScreenUtil().setWidth(50),
                                  height: ScreenUtil().setHeight(50),
                                  color: Color(0xffF54336),
                                  margin: EdgeInsets.fromLTRB(0, 0, 10, 0),
                                  child: Center(
                                    child: Text(
                                      "终3",
                                      textAlign: TextAlign.center,
                                      style: TextStyle(
                                        fontSize: ScreenUtil().setSp(30),
                                        color: Colors.white,
                                      ),
                                    ),
                                  ),
                                ),
                                Container(
                                  width: ScreenUtil().setWidth(400),
                                  child: Text(
                                    list[index]['toAddress'],
                                    overflow: TextOverflow.ellipsis,
                                    maxLines: 2,
                                    style: TextStyle(
                                      fontSize: ScreenUtil().setSp(32),
                                      color: Color(0xff0E0E0E),
                                    ),
                                  ),
                                ),
                              ],
                            )
                          ],
                        ),
                      ),
                    )),
                Expanded(
                  child: Container(
                    color: Color.fromRGBO(255, 255, 255, 0.8),
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: <Widget>[
                        Image.asset('images/received.png'),
                        FlatButton(
                            child: Text(
                              "已收货",
                              style: TextStyle(
                                color: Color(0xffFB5858),
                                fontSize: ScreenUtil().setSp(30),
                              ),
                            ),
                            onPressed: () {})
                      ],
                    ),
                  ),
                )
              ],
            ),
          ),

          ///联系人电话
          SizedBox(
            height: ScreenUtil().setHeight(30),
          ),
          Divider(),
          getMoreWidget(hasmore),
        ],
      ),
    );
  } else {
    return Container(
      child: Column(
        children: <Widget>[
          ///起点 终点  和轨迹 Row排列方便
          Container(
            decoration:
                BoxDecoration(color: Colors.white, boxShadow: <BoxShadow>[
              BoxShadow(
                color: Colors.grey[400],
              ),
            ]),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: <Widget>[
                Expanded(
                    flex: 3,
                    child: Container(
                      color: Color.fromRGBO(255, 255, 255, 1),
                      child: Padding(
                        padding: EdgeInsets.fromLTRB(20, 10, 0, 10),
                        child: Column(
                          children: <Widget>[
                            Row(
                              children: <Widget>[
                                Container(
                                  width: ScreenUtil().setWidth(400),
                                  child: Text(
                                    list[index]['name'],
                                    overflow: TextOverflow.ellipsis,
                                    maxLines: 2,
                                    style: TextStyle(
                                      fontSize: ScreenUtil().setSp(32),
                                      color: Color(0xff0E0E0E),
                                      fontWeight: FontWeight.bold,
                                    ),
                                  ),
                                ),
                              ],
                            ),

                            ///起点
                            Row(
                              children: <Widget>[
                                Container(
                                  width: ScreenUtil().setWidth(45),
                                  height: ScreenUtil().setHeight(45),
                                  color: Color(0xff62B500),
                                  margin: EdgeInsets.fromLTRB(0, 10, 10, 0),
                                  child: Center(
                                    child: Text(
                                      "起",
                                      textAlign: TextAlign.center,
                                      style: TextStyle(
                                        fontSize: ScreenUtil().setSp(30),
                                        color: Colors.white,
                                      ),
                                    ),
                                  ),
                                ),
                                Container(
                                  width: ScreenUtil().setWidth(400),
                                  margin: EdgeInsets.fromLTRB(0, 10, 0, 0),
                                  child: Text(
                                    list[index]['fromAddress'],
                                    overflow: TextOverflow.ellipsis,
                                    maxLines: 2,
                                    style: TextStyle(
                                      fontSize: ScreenUtil().setSp(32),
                                      color: Color(0xff0E0E0E),
                                    ),
                                  ),
                                ),
                              ],
                            ),
                            Container(
                              height: ScreenUtil().setHeight(35),
                              margin: EdgeInsets.fromLTRB(
                                  ScreenUtil().setHeight(20), 0, 0, 0),
                              decoration: BoxDecoration(
                                border: Border(
                                    left: BorderSide(
                                        color: Colors.grey[200],
                                        width: 1,
                                        style: BorderStyle.solid)),
                              ),
                            ),

                            ///终点
                            Row(
                              children: <Widget>[
                                Container(
                                  width: ScreenUtil().setWidth(45),
                                  height: ScreenUtil().setHeight(45),
                                  color: Color(0xffF54336),
                                  margin: EdgeInsets.fromLTRB(0, 0, 10, 0),
                                  child: Center(
                                    child: Text(
                                      "终",
                                      textAlign: TextAlign.center,
                                      style: TextStyle(
                                        fontSize: ScreenUtil().setSp(30),
                                        
                                        color: Colors.white,
                                      ),
                                    ),
                                  ),
                                ),
                                Container(
                                  width: ScreenUtil().setWidth(400),
                                  child: Text(
                                    list[index]['toAddress'],
                                    overflow: TextOverflow.ellipsis,
                                    maxLines: 2,
                                    style: TextStyle(
                                      fontSize: ScreenUtil().setSp(32),
                                      color: Color(0xff0E0E0E),
                                    ),
                                  ),
                                ),
                              ],
                            )
                          ],
                        ),
                      ),
                    )),
                Expanded(
                  child: Container(
                    color: Color.fromRGBO(255, 255, 255, 0.8),
                    margin: EdgeInsets.fromLTRB(0, 40, 0, 0),
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: <Widget>[
                        Image.asset('images/received.png'),
                        FlatButton(
                            child: Text(
                              "已收货",
                              style: TextStyle(
                                color: Color(0xffFB5858),
                                fontSize: ScreenUtil().setSp(30),
                              ),
                            ),
                            onPressed: () {})
                      ],
                    ),
                  ),
                )
              ],
            ),
          ),

          ///联系人电话
          SizedBox(
            height: ScreenUtil().setHeight(20),
          ),
        ],
      ),
    );
  }
}

//加载中的圈圈
Widget getMoreWidget(hasMore) {
  if (hasMore) {
    return Center(
      child: Padding(
        padding: EdgeInsets.all(10.0),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            Text(
              '加载中...',
              style: TextStyle(fontSize: 16.0),
            ),
            CircularProgressIndicator(
              strokeWidth: 1.0,
            )
          ],
        ),
      ),
    );
  } else {
    return Center(
      child: Text("--我是有底线的--"),
    );
  }
}
